# Maintainer: @naveen521kk on Github, Naveen M K <naveen@syrusdark.website>

_realname=manimpango
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.2.6
pkgrel=1
pkgdesc="Bindings for Pango for using with Manim. (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url='https://github.com/ManimCommunity/ManimPango'
license=('GPL3')
depends=("${MINGW_PACKAGE_PREFIX}-python"
          "${MINGW_PACKAGE_PREFIX}-pango")
makedepends=("${MINGW_PACKAGE_PREFIX}-cython"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/ManimCommunity/ManimPango/releases/download/v${pkgver}/manimpango-${pkgver}.tar.gz")
sha512sums=('4944ca2c3afa7bad54738d7d9c81c3c7d8348eac40fd5614a8f1f430ec85084de10de0bd1d970edd4cd3674bbdec375ca86351cf2ce0a7d429409fd6d32d72d8')

prepare() {
  # Force cython rebuild
  rm -f ${_realname}-${pkgver}/manimpango/*.c
  rm -rf python-build-${CARCH} | true
  cp -r "${_realname}-${pkgver}" "python-build-${CARCH}"
}

build() {  
  msg "Python build for ${CARCH}"
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
